import allure
from page_object.roncoo_login import RoncooLogin
from page_element.el_user import *
import logging
from utils.timer import sleep


class Recnoo_add(RoncooLogin):
    """首页搜索商品后退出登录"""

    def recnoo_addyh(self, yhmc, sjh, dlmm, expected):
        # 前置条件：已登录
        self.roncoo_login()
        with allure.step(f"点击用户管理"):
            self.click(recnoo.recnoo_yggl)
            sleep(2)
        with allure.step(f"点击用户信息"):
            self.click(recnoo.recnoo_yyxx)
        with allure.step(f"点击添加按钮"):
            self.click(recnoo.recnoo_tjan)
        with allure.step(f"输入用户名称"):
            self.send_keys(recnoo.recnoo_yhmc, yhmc)
            sleep(2)
        with allure.step(f"输入手机号"):
            self.send_keys(recnoo.recnoo_sjh, sjh)
            sleep(2)
        with allure.step(f"输入登录密码"):
            self.send_keys(recnoo.recnoo_dlmm, dlmm)
            sleep(2)
        with allure.step(f"点击提交按钮"):
            self.click(recnoo.recnoo_tijan)
            sleep(2)
        with allure.step(f"断言"):
            dy = self.text(recnoo.recnoo_dy)
            assert expected == dy
